/*
 * ImageDecoderEx.h
 *
 *  Created on: 2 janv. 2011
 *      Author: Serge
 */

#ifndef IMAGEDECODEREX_H_
#define IMAGEDECODEREX_H_

#include "imageconversion.h"
#include "e32msgqueue.h"


class CImageDecoderEx
	{
private:
	struct CRemote;
	
	struct CThreadCallback;
	static TInt ThreadFunction(TAny* aPtr);
	static RThread sWorkerThread;
	static CAsyncCallBack* sAsyncCallback;
	static RFs sFs;
	struct TThreadMessage
		{
		enum TOperation { INIT, DATANEWL, CONVERT, CANCEL, DELETE, EXIT_THREAD } iOperation;
		CRemote* iRemote;
		const TDesC8* iSourceData;
		TRequestStatus* iConvertStatus;
		TInt iDestinationHandle;
		TThreadId iThreadId;		
		};
	static RMsgQueue<TThreadMessage> sMsgQueue;
	
	CRemote* iRemote;
	CImageDecoder* iImageDecoder;
	
public:
	static CImageDecoderEx* DataNewL(RFs& aFs, const TDesC8& aSourceData, const CImageDecoder::TOptions aOptions = CImageDecoder::EOptionNone);
	void Convert(TRequestStatus* aRequestStatus, CFbsBitmap& aDestination);
	void Cancel();
	CImageDecoderEx();
	virtual ~CImageDecoderEx();
	const TFrameInfo& FrameInfo(TInt aFrameNumber = 0) const;
	
	
	static void StartThread();
	static void StopThread();
	
	
	};


#endif /* IMAGEDECODEREX_H_ */
